package client_V1;
// <editor-fold defaultstate="collapsed" desc="Imports">
import lib.StreamSocket;
import clientMain.Transmitter;
import java.io.IOException;
import java.net.Socket;
import java.net.UnknownHostException;
// </editor-fold>
/**
 * @file ClientThread.java
 *
 * @version 0.1
 * @author Chris Sewell 10008342
 */
public class ClientThreadV1 extends Thread {
    // <editor-fold defaultstate="collapsed" desc="Attributes">

    StreamSocket streamServer;
    Socket requestSocket;
    Receiver rx;
    Transmitter tx;
// </editor-fold>
    // <editor-fold defaultstate="collapsed" desc="Constructors">

    public ClientThreadV1(String host, int port) throws UnknownHostException, IOException {

        requestSocket = new Socket(host, port);
        streamServer = new StreamSocket(requestSocket);//Send connection request to server
        System.out.print("Connected\n");
        tx = new Transmitter(streamServer);//Set up transmitter thread
        rx = new Receiver(streamServer);//Set up receiver thread
    }
    // </editor-fold>
    // <editor-fold defaultstate="collapsed" desc="Methods">

    @Override
    public void run() {
        tx.start();//Start transmitt and receive threads
        rx.start();
    }
    // </editor-fold> 
}
